package com.purengage.ipilih;

import java.util.ArrayList;
import com.purengage.ipilih.lib.EntryAdapterRelawan;
import com.purengage.ipilih.lib.EntryItem;
import com.purengage.ipilih.lib.Item;
import com.purengage.ipilih.lib.SectionItem;

import android.view.View.OnClickListener;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.Toast;

public class Responden extends Activity implements OnItemClickListener{
	public ListAdapter adapter;
	ArrayList<Item> items = new ArrayList<Item>();
	ListView listview;
	View header;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_responden);
		
		Bundle extras = getIntent().getExtras();
		final String id = extras.getString("id");	
		
		listview = (ListView) findViewById(R.id.listresponden);
		items.add(new SectionItem("Daftar Responden"));
		
		for (int i = 0; i < 10; i++) {
			items.add(new EntryItem(R.drawable.status_g, "Relawan A", null, null, null));	
		}
		EntryAdapterRelawan adapter = new EntryAdapterRelawan(this, items);
	
		
		header = getLayoutInflater().inflate(R.layout.header_relawan, null);
		listview.addHeaderView(header);
		
		header.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				Intent j = new Intent(v.getContext(), AddResponden.class);
				j.putExtra("id", id);
				startActivity(j);
			}
		});
		listview.setAdapter(adapter);
		listview.setOnItemClickListener(this);
		
	}

	@Override
	public void onItemClick(AdapterView<?> arg0, View arg1, int position, long arg3) {
		
		EntryItem item = (EntryItem)items.get(position);
		Toast.makeText(this, "You clicked " + item.title , Toast.LENGTH_SHORT).show();
	}
	
}
